﻿/* Created by Richard Fleming
 * Copyright 2009 Johnson County Community College
 * Free for non-commercial use
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace XnaUtility.UI
{
    /// <summary>
    /// The most basic UI Element possible.
    /// </summary>
    /// 
    [Serializable, XmlRoot("UI_Element")]
    public class UI_Element
    {
        public Texture2D Background { get; set; }
        public Vector2 Location { get; set; }
        public Rectangle Boundry { get; set; }
        public string ImageName { get; set; }
        public Vector2 Scale { get; set; }

        public delegate void Clicked_Event(UI_Element target);
        public event Clicked_Event Clicked;

        protected int drawOrder;
        protected float scaledDrawOrder;

        public bool WasClicked(Point target)
        {
            bool result;
            Boundry.Contains(ref target, out result);
            if (result)
            {
                if (Clicked != null) Clicked(this);
            }
            return result;
        }
    }
}
